package com.lianjinsu.shop.entity.enums;

import com.baomidou.mybatisplus.annotation.IEnum;
import lombok.AccessLevel;
import lombok.Getter;
import lombok.RequiredArgsConstructor;

@Getter
@RequiredArgsConstructor(access = AccessLevel.PRIVATE)
public enum OrderStatus implements IEnum<Integer> {
    UNPAID(1), PAID(2), COMPLETE(3), UNPAID_TIMEOUT(4), CANCEL(-1);

    private final int status;

    public static OrderStatus ofStatus(int status) {
        for (OrderStatus orderStatus : values()) {
            if (orderStatus.getStatus() == status) {
                return orderStatus;
            }
        }
        return null;
    }

    @Override
    public Integer getValue() {
        return status;
    }
}
